<!--
 * @Author: your name
 * @Date: 2021-11-10 21:21:07
 * @LastEditTime: 2021-11-10 21:29:46
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue-note\day01\10.v-if和v-else.html
-->
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>10.v-if和v-else和v-show</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- v-show是调整css中display -->
      <div v-show="isLogin">hhh</div>
      <div v-if="isLogin">你好</div>
      <div v-else>请登录后操作</div>
      <button @click="handleLogin" v-if="!isLogin">登录</button>
      <button @click="handleLogin" v-else>注销</button>
    </div>
    <script>
      new Vue({
        el: "#app",
        data: {
          isLogin: true,
        },
        methods: {
          handleLogin() {
            this.isLogin = this.isLogin ? false : true;
          },
        },
      });
    </script>
  </body>
</html>
